<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>
<script>
  //字符串特别长如何判断字符串中有数字
  var arr = "qwd3kRnn2rasdtry5gdb7";

    //方法一
    var arr = /\d/.test(arr);
    console.log(arr); //true

  //方法二
  for (var i = 0; i < arr.length; i++) {
    var num = Number(arr[i]);
    // var num =arr[i].toString( )
    if (num) {
      console.log("数据中有数字" + num);
    } else {
      console.log("数据中有字母" + arr[i]);
    }
  }

    //方法三
    function lcFun(arr) {
      for (var i = 0; i < 10; i++) {
        if (arr.indexOf(i) != -1) {
          return true;
        }
      }
      return false;
    }
    console.log(lcFun(arr));
</script>
